package com.yantong.pay.yfz.domain.cust;


import com.yantong.pay.yfz.domain.cust.domain.business.apply.MerchantBusinessApplyRequest;
import com.yantong.pay.yfz.domain.cust.domain.business.apply.MerchantBusinessApplyResponse;
import com.yantong.pay.yfz.domain.cust.domain.business.modify.MerchantBusinessModifyRequest;
import com.yantong.pay.yfz.domain.cust.domain.business.modify.MerchantBusinessModifyResponse;
import com.yantong.pay.yfz.domain.cust.domain.business.query.MerchantBusinessQueryRequest;
import com.yantong.pay.yfz.domain.cust.domain.business.query.MerchantBusinessQueryResponse;
import com.yantong.pay.yfz.domain.cust.domain.merchant.request.SpAountSplitRequest;
import com.yantong.pay.yfz.domain.cust.domain.merchant.request.SpMerchantRequest;
import com.yantong.pay.yfz.domain.cust.domain.merchant.response.*;
import com.yantong.pay.yfz.util.Config;
import com.yantong.pay.yfz.util.RemoteInvoker;

/**
 * @Author: gewencai@epaylinks.cn
 * @Date: 2019/5/5 11:32
 * @Description 统一进件系统SDK辅助类
 * @Version 1.0
 */
public class CustHelper {

	/**
	 * 商户进件
	 *
	 * @param request
	 * @return
	 * @throws Exception
	 */
	public static SpMerchantApplyResponse spMerchantApply(SpMerchantRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception {
		return RemoteInvoker.invoke(request, Config.getSpMerchantApplyUrl(), yplPrivateKey, yplPrivateKeyPwd, yplSignNo, publicKeyFileUri, SpMerchantApplyResponse.class);
	}

	/**
	 * 商户信息更新
	 *
	 * @param request
	 * @return
	 * @throws Exception
	 */
	public static SpMerchantUpdateResponse spMerchantUpdate(SpMerchantRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception {
		return RemoteInvoker.invoke(request, Config.getSpMerchantUpdateUrl(), yplPrivateKey, yplPrivateKeyPwd, yplSignNo, publicKeyFileUri, SpMerchantUpdateResponse.class);
	}

	/**
	 * 商户信息查询
	 *
	 * @param request
	 * @return
	 * @throws Exception
	 */
	public static SpMerchantQueryResponse spMerchantQuery(SpMerchantRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception {
		return RemoteInvoker.invoke(request, Config.getSpMerchantQueryUrl(), yplPrivateKey, yplPrivateKeyPwd, yplSignNo, publicKeyFileUri, SpMerchantQueryResponse.class);
	}

	/**
	 * 商户结算卡信息列表
	 *
	 * @param request
	 * @return
	 * @throws Exception
	 */
	public static SettleAccountQueryResponse spSettAccountQuery(SpMerchantRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception {
		return RemoteInvoker.invoke(request, Config.getSpSettAccountQueryUrl(), yplPrivateKey, yplPrivateKeyPwd, yplSignNo, publicKeyFileUri, SettleAccountQueryResponse.class);
	}


	/**
	 * 商户业务申请
	 *
	 * @param request 申请请求
	 * @return 申请响应
	 * @throws Exception
	 */
	public static MerchantBusinessApplyResponse merchantBusinessApply(MerchantBusinessApplyRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception {
		return RemoteInvoker.invoke(request, Config.getMerchantBusinessApplyUrl(), yplPrivateKey, yplPrivateKeyPwd, yplSignNo, publicKeyFileUri, MerchantBusinessApplyResponse.class);
	}

	/**
	 * 商户业务查询
	 *
	 * @param request 查询请求
	 * @return 查询响应
	 * @throws Exception
	 */
	public static MerchantBusinessQueryResponse merchantBusinessQuery(MerchantBusinessQueryRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception {
		return RemoteInvoker.invoke(request, Config.getMerchantBusinessQueryUrl(), yplPrivateKey, yplPrivateKeyPwd, yplSignNo, publicKeyFileUri, MerchantBusinessQueryResponse.class);
	}

	/**
	 * 商户业务修改
	 *
	 * @param request 修改请求
	 * @return 修改响应
	 * @throws Exception
	 */
	public static MerchantBusinessModifyResponse merchantBusinessModify(MerchantBusinessModifyRequest request, String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception {
		System.out.println(Config.getMerchantBusinessModifyUrl());
		return RemoteInvoker.invoke(request, Config.getMerchantBusinessModifyUrl(), yplPrivateKey, yplPrivateKeyPwd, yplSignNo, publicKeyFileUri, MerchantBusinessModifyResponse.class);
	}

	/**
	 * 账户分账
	 * @param request
	 * @return
	 * @throws Exception
	 */
	public static SpAountSplitResponse accountSplitQuery(SpAountSplitRequest request,String yplPrivateKey, String yplPrivateKeyPwd, String yplSignNo, String publicKeyFileUri) throws Exception {
		System.out.println(Config.getAccountSplitQueryUrl());
		return RemoteInvoker.invoke(request, Config.getAccountSplitQueryUrl(), yplPrivateKey, yplPrivateKeyPwd, yplSignNo, publicKeyFileUri, SpAountSplitResponse.class);
	}
}
